package com.peng.leetcode.array;

/**
 * CheckPossibility
 * <p>
 * 665. 非递减数列
 *
 * @author: lupeng6
 * @create: 2021/2/7 15:23
 */
public class CheckPossibility {

    public static void main(String[] args) {
        int[] arr = {3, 4, 2, 3};
        System.out.println(new CheckPossibility().checkPossibility(arr));
    }


    public boolean checkPossibility(int[] nums) {
        int count = 0;
        int len = nums.length;
        for (int i = 0; i < len - 1; i++) {
            if (nums[i] > nums[i + 1]) {
                nums[i + 1] = nums[i];
                count++;
            }
            if (count > 1) {
                return false;
            }
        }
        return true;
    }
}
